import uedit from '../../config/uedit';
var multiparty = require('multiparty');

export function UploadPhoto(req, res, next) {
 	//生成multiparty对象，并配置上传目标路径
 	var form = new multiparty.Form({uploadDir: 'images/'});

 	//上传完成后处理	
	form.parse(req, function(err, fields, files) {
	 	var file = files.files[0];
	 	res.json({
	 		"state": "SUCCESS",
		    "url": '/' + file.path,
		    "title": file.originalFilename,
		    "original": file.originalFilename
	 	});
	});
}

export function UploadPhoto_GET(req, res, next) {
	res.json(uedit.conf);return;
}